$(function () {
    $(function () {
        var options = {
            modalName: "店铺",
            url: "/render/shopManager/list",
            getInfoUrl: "/render/shopManager/get/{id}",
            updateUrl: "/render/shopManager/edit",
            removeUrl: "/render/shopManager/remove",
            createUrl: "/render/shopManager/add",
            searchUrl: "/render/shopManager/search",
            pageNumber:1,
            pageSize:7,
            columns: [
                {
                    checkbox: true,
                    formatter:checkboxMatter
                }, {
                    field: 'id',
                    title: 'ID',
                    align: "center",
                    width: '50px',
                    class:"colStyle",
                    sortable : true,
                    formatter:paramsMatter
                }, {
                    field: 'shop_name',
                    title: '店铺名字',
                    align: "center",
                    width: '100px',
                    class:"colStyle",
                    formatter:paramsMatter
                }, {
                    field: 'user_id',
                    title: '店长ID',
                    align: "center",
                    width: '88px',
                    class:"colStyle",
                    formatter:paramsMatter
                }, {
                    field: 'sale_count',
                    title: '销量',
                    align: "center",
                    width: '88px',
                    class:"colStyle",
                    formatter:paramsMatter
                }, {
                    field: 'popularity',
                    title: '浏览量',
                    align: "center",
                    width: '88px',
                    class:"colStyle",
                    formatter:paramsMatter
                }, {
                    field: 'create_time',
                    title: '创建时间',
                    width: '88px',
                    align: "center",
                    sortable : true,
                    cellStyle:formatTableUnit,
                    formatter:paramsMatter
                }, {
                    field: 'update_time',
                    title: '更新时间',
                    width: '88px',
                    align: "center",
                    sortable : true,
                    cellStyle:formatTableUnit,
                    formatter:paramsMatter
                }, {
                    field: 'operate',
                    title: '操作',
                    align: "center",
                    width: '100px',
                    formatter: operateFormatter //自定义方法，添加操作按钮
                }
            ]
        };

        // 初始化table组件
        var table = new Table(options);
        table.init();

        //search按钮绑定查询事件
        $('#btnSearch').on('click', function () {
            var searchtext = {
                id: $("#search-id").val(),
                shop_name: $("#search-shop_name").val(),
                user_id: $("#search-user_id").val()
            };

            if($("#search-id").val() === ""&&$("#search-shop_name").val() === ""&&$("#search-user_id").val() === ""){
                postParams(options.url,options.onExpandRow,options,options.rowStyle,options.columns,null,true);
            }else {
                postParams(options.searchUrl,options.onExpandRow,options,options.rowStyle,options.columns,JSON.stringify(searchtext),false);
            }
        });
    });

    $(".close,.btn-default").on("click",function () {
        $(".modal").css("display","");
        $(".modal").removeClass("in");
        $(".modal-backdrop").removeClass("in");
    });

    $(".close,.btn-default").on("click",function () {
        $(".modal").css("display","");
        $(".modal").removeClass("in");
        $(".modal-backdrop").removeClass("in");
    });
});